package spring_test;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ContainerExtensionPointsTest {
	 public static void main(final String[] args) throws Exception {
	      ApplicationContext ctx = new ClassPathXmlApplicationContext("spring_test/container_extension_points_conf.xml");
	      CarBean car = (CarBean) ctx.getBean("car01");
	      System.out.println(car.getName());
	  }
}

class InstantiationTracingBeanPostProcessor01 implements BeanPostProcessor {
	// simply return the instantiated bean as-is
	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		return bean; // we could potentially return any object reference here...
	}

	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("BeanPostProcessor01 : Bean '" + beanName + "' created : "
				+ bean.toString());
		return bean;
	}
}

class InstantiationTracingBeanPostProcessor02 implements BeanPostProcessor {
	// simply return the instantiated bean as-is
	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		return bean; // we could potentially return any object reference here...
	}

	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("BeanPostProcessor02 : Bean '" + beanName + "' created : "
				+ bean.toString());
		return bean;
	}
}

class CarBean		{
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}